package com.example.concurrent.demo.deadLock;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LockB implements Runnable{
    @Override
    public void run(){
        try{
            log.info("LockB running");
            while(true){
                synchronized(DeadLockTest.obj2){
                    log.info("LockB lock obj2");
                    Thread.sleep(1000);
                    synchronized(DeadLockTest.obj1){
                        log.info("LockB lock obj1");
                    }
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}